$(function() {
	admin.subject.init();
});
Namespace('admin.subject', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
				/*var row = $('#datagrid').datagrid('getSelected');
				admin.supplier.edit(row.id);*/
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	toAdd : function() {
		top.addTab('#tabs','添加专区', contextPath+'/mall/subject/add');
	},
	edit:function(id) {
		if(id==null) {
			top.showInfo('请选择需要修改的记录!');
			return;
		}
		top.addTab(id,'专区编辑', contextPath+'/mall/subject/update/'+id);
	},
	addImg:function(id){
		getDialog('query-dialog').dialog({
			href:contextPath+'/mall/subject/imgUpload',
			title: '选择文件',
		    width: 350,
		    height: 250,
		    buttons:[{
				text:'上传',
				handler:function(){
					uploaderStart(id);
				}
			}]
		});
		
	},
	toProductList : function(id,title) {
		if(id==null) {
			top.showInfo('请选择专区!');
			return;
		}
		top.addTab('#tabs',title+'商品', contextPath+'/mall/subject/product/list/'+id);
	},
	reloadDG: function(){ 
		$('#datagrid').datagrid('reload');  
	}  
});